/**
 * 创建游戏得场地
 */
module m {
	export class Ground extends egret.Sprite {
		//游戏场景
		public Self: gameScene;
		public constructor(_self: gameScene) {
			super();
			this.Self = _self;

			this.createGround();
			this.createBox();
			this.createWall();
		}

		/**
		 * 创建陆地
		 */
		public createGround() {
			let geometry = new THREE.BoxGeometry(28, 0.2, 11);
			let material = new Physijs.createMaterial(
				new THREE.MeshLambertMaterial({
					map: this.Self.textLoader.load('https://fs-ews.oss-cn-hangzhou.aliyuncs.com/main/m/ballshot_m/image/game_floor.jpg')
				}),
				0.4,
				0.8
			)
			let Ground = new Physijs.BoxMesh(geometry, material, 0);
			Ground.receiveShadow = true;
			Ground.name = 'ground';
			Ground.position.set(0, 0, -5)
			gameScene.Scene.add(Ground);
		}

		/**
		 * 创建背景得牌子
		 */
		public createBox() {
			//左边得广告牌
			let geometry = new THREE.BoxGeometry(8.3, 2.5, 0.2);
			let material = new Physijs.createMaterial(
				new THREE.MeshLambertMaterial({
					// map: this.Self.textLoader.load(gameData.localUrl + '/game_floor.jpg')
					map: this.Self.textLoader.load('https://fs-ews.oss-cn-hangzhou.aliyuncs.com/main/m/ballshot_m/image/game_footballbox.jpg')
				}),
				0.4,//摩擦力
				0.8//恢复力 弹力
			)
			let fBox = new Physijs.BoxMesh(geometry, material, 0);
			fBox.receiveShadow = true;
			fBox.position.set(-10.15, 1.25, -10)
			gameScene.Scene.add(fBox)
			//中间得广告牌
			let material2 = new Physijs.createMaterial(
				new THREE.MeshLambertMaterial({
					map: this.Self.textLoader.load('https://fs-ews.oss-cn-hangzhou.aliyuncs.com/main/m/ballshot_m/image/game_green.jpg')
				}),
				0.4,//摩擦力
				0.8//恢复力 弹力
			)
			let geometry2 = new THREE.BoxGeometry(12, 2.5, 0.2);
			let fBox1 = new Physijs.BoxMesh(geometry2, material2, 0);
			fBox1.receiveShadow = true;
			fBox1.position.set(-0, 1.25, -10)
			gameScene.Scene.add(fBox1)
			//右面得广告牌
			let geometry3 = new THREE.BoxGeometry(8.3, 2.5, 0.2);
			let material3 = new Physijs.createMaterial(
				new THREE.MeshLambertMaterial({
					// map: this.Self.textLoader.load(gameData.localUrl + '/game_floor.jpg')
					map: this.Self.textLoader.load('https://fs-ews.oss-cn-hangzhou.aliyuncs.com/main/m/ballshot_m/image/game_matchbox.jpg')
				}),
				0.4,//摩擦力
				0.8//恢复力 弹力
			)
			let fBox3 = new Physijs.BoxMesh(geometry3, material3, 0);
			fBox3.receiveShadow = true;
			fBox3.position.set(10.15, 1.25, -10)
			gameScene.Scene.add(fBox3)
		}

		/**
		 * 创建背景墙
		 */
		public createWall() {
			let geometry = new THREE.BoxGeometry(29, 7.5, 0.2);
			let material = new Physijs.createMaterial(
				new THREE.MeshLambertMaterial({
					// map: this.Self.textLoader.load(gameData.localUrl + '/game_bg.jpg')
					map: this.Self.textLoader.load('https://fs-ews.oss-cn-hangzhou.aliyuncs.com/main/m/ballshot_m/image/game_bgbox.jpg')
				}),
				0.4,//摩擦力
				0.8//恢复力 弹力
			)
			let Wall = new Physijs.BoxMesh(geometry, material, 0);
			Wall.receiveShadow = true;
			Wall.name = 'ground';
			Wall.position.set(0, 6.25, -10.2)
			gameScene.Scene.add(Wall);
		}
	}
}